package org.guohao.mockdata.utils;

import java.util.List;
import javafx.geometry.Side;
import javafx.scene.Node;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
import javafx.scene.input.ContextMenuEvent;

@SuppressWarnings("restriction")
public class GlobalContextMenu extends ContextMenu {

  private static GlobalContextMenu instance=null;

  public static GlobalContextMenu getInstance() {
    if (instance == null) {
      instance = new GlobalContextMenu();
    }
    return instance;
  }
  private GlobalContextMenu() {
  }

  public void show(ContextMenuEvent event,List<MenuItem> menus) {
    getItems().clear();
    getItems().addAll(menus);
    Node node = event.getPickResult().getIntersectedNode();
    super.show(node, Side.BOTTOM, event.getX(), 0);
  }
}